﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Web;
using WMSTest.OnlineMapRequests;
using WMSTest.WebMapResource;

namespace WMSTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string filePath = "test/";

            //ArcGIS REST API Test
            //Hydro BaseMap 
            string hydroBaseMapUrl = "http://bmproto.esri.com/ArcGIS/rest/services/Hydro/HydroBase2009/MapServer/export";

            ArcOnlineRESTMapRequest arcOnlineRESTMapRequest = new ArcOnlineRESTMapRequest(hydroBaseMapUrl);
            OnlineMapResource arcOnlineProvider = new OnlineMapResource(arcOnlineRESTMapRequest);
            Extent arcOnlineTestExtent = new Extent(-11144398.7965, 3375646.035, -10562901.908, 3763310.627);
            
            List<ImageTile> arcOnlineTiles = arcOnlineProvider.GetTiles(arcOnlineTestExtent, new MapSize(768, 512));

            foreach (ImageTile tile in arcOnlineTiles)
            {
                tile.WriteToFile(filePath, "arcHydro"+tile.Name, "png");
            }

            //////////////////////////////////////////////////////////////

            //World Street Map
            string streetMapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/export";

            arcOnlineRESTMapRequest = new ArcOnlineRESTMapRequest(streetMapUrl);
            arcOnlineProvider = new OnlineMapResource(arcOnlineRESTMapRequest);
            arcOnlineTestExtent = new Extent(-11144398.7965, 3375646.035, -10562901.908, 3763310.627);

            arcOnlineTiles = arcOnlineProvider.GetTiles(arcOnlineTestExtent, new MapSize(768, 512));

            foreach (ImageTile tile in arcOnlineTiles)
            {
                tile.WriteToFile(filePath, "arcStreet_" + tile.Name, "png");
            }

            //////////////////////////////////////////////////////////////
               
            //WMS Test
            string wmsUrl = "http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer";

            string[] layers = new string[] { "0", "1" };
            string[] styles = new string[] { "", "" };

            WMSMapRequest wmsMapRequest = new WMSMapRequest(wmsUrl, "1.3.0", layers, styles, "CRS:84");
            
            OnlineMapResource wmsOnlineProivder = new OnlineMapResource(wmsMapRequest);

            Extent wmsTestExtent = new Extent(-178.217598, 18.924782, -66.969271, 71.406235);

            List<ImageTile> wmsTiles = wmsOnlineProivder.GetTiles(wmsTestExtent, new MapSize(768, 512));

            foreach (ImageTile tile in wmsTiles)
            {
                tile.WriteToFile(filePath, "wms_" + tile.Name, "png");
            }

            ////////////////////////////////////////////////////////////

            //Google Static API Test

             

        }
    }
}
